import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class IODemo6 {
    public static void main(String[] args) throws IOException{
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            while(true){
                int a = inputStream.read();
                if(a == -1){
                    //文件读到末尾了，返回 - 1
                    break;
                }
                //System.out.println(a);
                System.out.printf("%x\n",a);
            }

        }
    }
    public static void main2(String[] args) throws IOException{
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream("./test.txt");
        } finally {
            inputStream.close();
        }
    }
    public static void main1(String[] args)  throws IOException{
        InputStream inputStream = new FileInputStream("./test.txt");
        System.out.println(inputStream.read());
        inputStream.close();
    }
}
